﻿#pragma once
/**
@author 何炜
@date 2011/4/28
@brief .
*/
#include "GLLObj.h"

namespace GLL
{

	/**物体管理.*/
	class ObjectManager
	{
	public:
		void Update_AllObjects(TimeMS);

		typedef std::vector<ObjSrdPtr> ObjectVec;
		void _GetTempObjectVec(OUT ObjectVec& ObjVec);

	protected:
		/**原始的创建函数.
		供子类条用*/
		ObjSrdPtr _CreateObject(Object::ID oid);

		/**原始的查找函数.
		供子类条用*/
		ObjSrdPtr _FindObject(Object::ID);

		/**原始的查找函数.
		供子类条用*/
		bool _HasObject(Object::ID);

		/**.*/
		ObjSrdPtr _DestroyObject(Object::ID);

	protected:
		typedef GLL_HashMap<Object::ID, ObjSrdPtr> ObjectMap;

		///所有管理的物品
		ObjectMap _objects;

		///_objects锁.
		GLL_Mutex _objMutex;

	private:
		/**保存物体.*/
		void AdoptObject( ObjSrdPtr pSrdObj );

		/**根据ID调用 _new_.*/
		Object* _new_Object(Object::ID i);

		/**.*/
		void _delete_Object(Object* p);

		//友元定义
		friend void boost::checked_delete(GLL::Object*);
	};
};//GLL
